<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ArithmeticUtils (Apache Commons Math 3.6.1 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="ArithmeticUtils (Apache Commons Math 3.6.1 API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/ArithmeticUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li><a href="../../../../../org/apache/commons/math3/util/BigReal.html" title="class in org.apache.commons.math3.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/util/ArithmeticUtils.html" target="_top">Frames</a></li>
<li><a href="ArithmeticUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.math3.util</div>
<h2 title="Class ArithmeticUtils" class="title">Class ArithmeticUtils</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.math3.util.ArithmeticUtils</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="strong">ArithmeticUtils</span>
extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Some useful, arithmetics related, additions to the built-in functions in
 <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html?is-external=true" title="class or interface in java.lang"><code>Math</code></a>.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#addAndCheck(int,%20int)">addAndCheck</a></strong>(int&nbsp;x,
           int&nbsp;y)</code>
<div class="block">Add two integers, checking for overflow.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#addAndCheck(long,%20long)">addAndCheck</a></strong>(long&nbsp;a,
           long&nbsp;b)</code>
<div class="block">Add two long integers, checking for overflow.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#binomialCoefficient(int,%20int)">binomialCoefficient</a></strong>(int&nbsp;n,
                   int&nbsp;k)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficient(int,%20int)"><code>CombinatoricsUtils.binomialCoefficient(int, int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#binomialCoefficientDouble(int,%20int)">binomialCoefficientDouble</a></strong>(int&nbsp;n,
                         int&nbsp;k)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficientDouble(int,%20int)"><code>CombinatoricsUtils.binomialCoefficientDouble(int, int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#binomialCoefficientLog(int,%20int)">binomialCoefficientLog</a></strong>(int&nbsp;n,
                      int&nbsp;k)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficientLog(int,%20int)"><code>CombinatoricsUtils.binomialCoefficientLog(int, int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#factorial(int)">factorial</a></strong>(int&nbsp;n)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorial(int)"><code>CombinatoricsUtils.factorial(int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#factorialDouble(int)">factorialDouble</a></strong>(int&nbsp;n)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorialDouble(int)"><code>CombinatoricsUtils.factorialDouble(int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#factorialLog(int)">factorialLog</a></strong>(int&nbsp;n)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorialLog(int)"><code>CombinatoricsUtils.factorialLog(int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#gcd(int,%20int)">gcd</a></strong>(int&nbsp;p,
   int&nbsp;q)</code>
<div class="block">Computes the greatest common divisor of the absolute value of two
 numbers, using a modified version of the "binary gcd" method.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#gcd(long,%20long)">gcd</a></strong>(long&nbsp;p,
   long&nbsp;q)</code>
<div class="block">
 Gets the greatest common divisor of the absolute value of two numbers,
 using the "binary gcd" method which avoids division and modulo
 operations.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#isPowerOfTwo(long)">isPowerOfTwo</a></strong>(long&nbsp;n)</code>
<div class="block">Returns true if the argument is a power of two.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#lcm(int,%20int)">lcm</a></strong>(int&nbsp;a,
   int&nbsp;b)</code>
<div class="block">
 Returns the least common multiple of the absolute value of two numbers,
 using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#lcm(long,%20long)">lcm</a></strong>(long&nbsp;a,
   long&nbsp;b)</code>
<div class="block">
 Returns the least common multiple of the absolute value of two numbers,
 using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#mulAndCheck(int,%20int)">mulAndCheck</a></strong>(int&nbsp;x,
           int&nbsp;y)</code>
<div class="block">Multiply two integers, checking for overflow.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#mulAndCheck(long,%20long)">mulAndCheck</a></strong>(long&nbsp;a,
           long&nbsp;b)</code>
<div class="block">Multiply two long integers, checking for overflow.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(java.math.BigInteger,%20java.math.BigInteger)">pow</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
   <a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;e)</code>
<div class="block">Raise a BigInteger to a BigInteger power.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(java.math.BigInteger,%20int)">pow</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
   int&nbsp;e)</code>
<div class="block">Raise a BigInteger to an int power.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(java.math.BigInteger,%20long)">pow</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
   long&nbsp;e)</code>
<div class="block">Raise a BigInteger to a long power.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(int,%20int)">pow</a></strong>(int&nbsp;k,
   int&nbsp;e)</code>
<div class="block">Raise an int to an int power.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(int,%20long)">pow</a></strong>(int&nbsp;k,
   long&nbsp;e)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>As of 3.3. Please use <a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(int,%20int)"><code>pow(int,int)</code></a> instead.</i></div>
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(long,%20int)">pow</a></strong>(long&nbsp;k,
   int&nbsp;e)</code>
<div class="block">Raise a long to an int power.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(long,%20long)">pow</a></strong>(long&nbsp;k,
   long&nbsp;e)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>As of 3.3. Please use <a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(long,%20int)"><code>pow(long,int)</code></a> instead.</i></div>
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#stirlingS2(int,%20int)">stirlingS2</a></strong>(int&nbsp;n,
          int&nbsp;k)</code>
<div class="block"><strong>Deprecated.</strong>&nbsp;
<div class="block"><i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#stirlingS2(int,%20int)"><code>CombinatoricsUtils.stirlingS2(int, int)</code></a></i></div>
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#subAndCheck(int,%20int)">subAndCheck</a></strong>(int&nbsp;x,
           int&nbsp;y)</code>
<div class="block">Subtract two integers, checking for overflow.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#subAndCheck(long,%20long)">subAndCheck</a></strong>(long&nbsp;a,
           long&nbsp;b)</code>
<div class="block">Subtract two long integers, checking for overflow.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long,%20int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="addAndCheck(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addAndCheck</h4>
<pre>public static&nbsp;int&nbsp;addAndCheck(int&nbsp;x,
              int&nbsp;y)
                       throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Add two integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - an addend</dd><dd><code>y</code> - an addend</dd>
<dt><span class="strong">Returns:</span></dt><dd>the sum <code>x+y</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be represented
 as an <code>int</code>.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.1</dd></dl>
</li>
</ul>
<a name="addAndCheck(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addAndCheck</h4>
<pre>public static&nbsp;long&nbsp;addAndCheck(long&nbsp;a,
               long&nbsp;b)
                        throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Add two long integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - an addend</dd><dd><code>b</code> - an addend</dd>
<dt><span class="strong">Returns:</span></dt><dd>the sum <code>a+b</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be represented as an long</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.2</dd></dl>
</li>
</ul>
<a name="binomialCoefficient(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficient</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;long&nbsp;binomialCoefficient(int&nbsp;n,
                                  int&nbsp;k)
                                throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                                       <a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a>,
                                       <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficient(int,%20int)"><code>CombinatoricsUtils.binomialCoefficient(int, int)</code></a></i></div>
<div class="block">Returns an exact representation of the <a
 href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
 Coefficient</a>, "<code>n choose k</code>", the number of
 <code>k</code>-element subsets that can be selected from an
 <code>n</code>-element set.
 <p>
 <Strong>Preconditions</strong>:
 <ul>
 <li> <code>0 &lt;= k &lt;= n </code> (otherwise
 <code>IllegalArgumentException</code> is thrown)</li>
 <li> The result is small enough to fit into a <code>long</code>. The
 largest value of <code>n</code> for which all coefficients are
 <code>&lt; Long.MAX_VALUE</code> is 66. If the computed value exceeds
 <code>Long.MAX_VALUE</code> an <code>ArithMeticException</code> is
 thrown.</li>
 </ul></p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - the size of the set</dd><dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n choose k</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a></code> - if <code>k &gt; n</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result is too large to be
 represented by a long integer.</dd></dl>
</li>
</ul>
<a name="binomialCoefficientDouble(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficientDouble</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;double&nbsp;binomialCoefficientDouble(int&nbsp;n,
                                          int&nbsp;k)
                                        throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                                               <a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a>,
                                               <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficientDouble(int,%20int)"><code>CombinatoricsUtils.binomialCoefficientDouble(int, int)</code></a></i></div>
<div class="block">Returns a <code>double</code> representation of the <a
 href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
 Coefficient</a>, "<code>n choose k</code>", the number of
 <code>k</code>-element subsets that can be selected from an
 <code>n</code>-element set.
 <p>
 <Strong>Preconditions</strong>:
 <ul>
 <li> <code>0 &lt;= k &lt;= n </code> (otherwise
 <code>IllegalArgumentException</code> is thrown)</li>
 <li> The result is small enough to fit into a <code>double</code>. The
 largest value of <code>n</code> for which all coefficients are <
 Double.MAX_VALUE is 1029. If the computed value exceeds Double.MAX_VALUE,
 Double.POSITIVE_INFINITY is returned</li>
 </ul></p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - the size of the set</dd><dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n choose k</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a></code> - if <code>k &gt; n</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result is too large to be
 represented by a long integer.</dd></dl>
</li>
</ul>
<a name="binomialCoefficientLog(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficientLog</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;double&nbsp;binomialCoefficientLog(int&nbsp;n,
                                       int&nbsp;k)
                                     throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                                            <a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a>,
                                            <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#binomialCoefficientLog(int,%20int)"><code>CombinatoricsUtils.binomialCoefficientLog(int, int)</code></a></i></div>
<div class="block">Returns the natural <code>log</code> of the <a
 href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
 Coefficient</a>, "<code>n choose k</code>", the number of
 <code>k</code>-element subsets that can be selected from an
 <code>n</code>-element set.
 <p>
 <Strong>Preconditions</strong>:
 <ul>
 <li> <code>0 &lt;= k &lt;= n </code> (otherwise
 <code>IllegalArgumentException</code> is thrown)</li>
 </ul></p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - the size of the set</dd><dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n choose k</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a></code> - if <code>k &gt; n</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result is too large to be
 represented by a long integer.</dd></dl>
</li>
</ul>
<a name="factorial(int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorial</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;long&nbsp;factorial(int&nbsp;n)
                      throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                             <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorial(int)"><code>CombinatoricsUtils.factorial(int)</code></a></i></div>
<div class="block">Returns n!. Shorthand for <code>n</code> <a
 href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the
 product of the numbers <code>1,...,n</code>.
 <p>
 <Strong>Preconditions</strong>:
 <ul>
 <li> <code>n &gt;= 0</code> (otherwise
 <code>IllegalArgumentException</code> is thrown)</li>
 <li> The result is small enough to fit into a <code>long</code>. The
 largest value of <code>n</code> for which <code>n!</code> <
 Long.MAX_VALUE} is 20. If the computed value exceeds <code>Long.MAX_VALUE</code>
 an <code>ArithMeticException </code> is thrown.</li>
 </ul>
 </p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - argument</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n!</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result is too large to be represented
 by a <code>long</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if <code>n &gt; 20</code>: The factorial value is too
 large to fit in a <code>long</code>.</dd></dl>
</li>
</ul>
<a name="factorialDouble(int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorialDouble</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;double&nbsp;factorialDouble(int&nbsp;n)
                              throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorialDouble(int)"><code>CombinatoricsUtils.factorialDouble(int)</code></a></i></div>
<div class="block">Compute n!, the<a href="http://mathworld.wolfram.com/Factorial.html">
 factorial</a> of <code>n</code> (the product of the numbers 1 to n), as a
 <code>double</code>.
 The result should be small enough to fit into a <code>double</code>: The
 largest <code>n</code> for which <code>n! &lt; Double.MAX_VALUE</code> is 170.
 If the computed value exceeds <code>Double.MAX_VALUE</code>,
 <code>Double.POSITIVE_INFINITY</code> is returned.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - Argument.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n!</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="factorialLog(int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorialLog</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;double&nbsp;factorialLog(int&nbsp;n)
                           throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#factorialLog(int)"><code>CombinatoricsUtils.factorialLog(int)</code></a></i></div>
<div class="block">Compute the natural logarithm of the factorial of <code>n</code>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - Argument.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>n!</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>n &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="gcd(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>gcd</h4>
<pre>public static&nbsp;int&nbsp;gcd(int&nbsp;p,
      int&nbsp;q)
               throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Computes the greatest common divisor of the absolute value of two
 numbers, using a modified version of the "binary gcd" method.
 See Knuth 4.5.2 algorithm B.
 The algorithm is due to Josef Stein (1961).
 <br/>
 Special cases:
 <ul>
  <li>The invocations
   <code>gcd(Integer.MIN_VALUE, Integer.MIN_VALUE)</code>,
   <code>gcd(Integer.MIN_VALUE, 0)</code> and
   <code>gcd(0, Integer.MIN_VALUE)</code> throw an
   <code>ArithmeticException</code>, because the result would be 2^31, which
   is too large for an int value.</li>
  <li>The result of <code>gcd(x, x)</code>, <code>gcd(0, x)</code> and
   <code>gcd(x, 0)</code> is the absolute value of <code>x</code>, except
   for the special cases above.</li>
  <li>The invocation <code>gcd(0, 0)</code> is the only one which returns
   <code>0</code>.</li>
 </ul></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>p</code> - Number.</dd><dd><code>q</code> - Number.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the greatest common divisor (never negative).</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result cannot be represented as
 a non-negative <code>int</code> value.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.1</dd></dl>
</li>
</ul>
<a name="gcd(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>gcd</h4>
<pre>public static&nbsp;long&nbsp;gcd(long&nbsp;p,
       long&nbsp;q)
                throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><p>
 Gets the greatest common divisor of the absolute value of two numbers,
 using the "binary gcd" method which avoids division and modulo
 operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef
 Stein (1961).
 </p>
 Special cases:
 <ul>
 <li>The invocations
 <code>gcd(Long.MIN_VALUE, Long.MIN_VALUE)</code>,
 <code>gcd(Long.MIN_VALUE, 0L)</code> and
 <code>gcd(0L, Long.MIN_VALUE)</code> throw an
 <code>ArithmeticException</code>, because the result would be 2^63, which
 is too large for a long value.</li>
 <li>The result of <code>gcd(x, x)</code>, <code>gcd(0L, x)</code> and
 <code>gcd(x, 0L)</code> is the absolute value of <code>x</code>, except
 for the special cases above.
 <li>The invocation <code>gcd(0L, 0L)</code> is the only one which returns
 <code>0L</code>.</li>
 </ul></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>p</code> - Number.</dd><dd><code>q</code> - Number.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the greatest common divisor, never negative.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result cannot be represented as
 a non-negative <code>long</code> value.</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.1</dd></dl>
</li>
</ul>
<a name="lcm(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lcm</h4>
<pre>public static&nbsp;int&nbsp;lcm(int&nbsp;a,
      int&nbsp;b)
               throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><p>
 Returns the least common multiple of the absolute value of two numbers,
 using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.
 </p>
 Special cases:
 <ul>
 <li>The invocations <code>lcm(Integer.MIN_VALUE, n)</code> and
 <code>lcm(n, Integer.MIN_VALUE)</code>, where <code>abs(n)</code> is a
 power of 2, throw an <code>ArithmeticException</code>, because the result
 would be 2^31, which is too large for an int value.</li>
 <li>The result of <code>lcm(0, x)</code> and <code>lcm(x, 0)</code> is
 <code>0</code> for any <code>x</code>.
 </ul></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - Number.</dd><dd><code>b</code> - Number.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the least common multiple, never negative.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result cannot be represented as
 a non-negative <code>int</code> value.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.1</dd></dl>
</li>
</ul>
<a name="lcm(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lcm</h4>
<pre>public static&nbsp;long&nbsp;lcm(long&nbsp;a,
       long&nbsp;b)
                throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><p>
 Returns the least common multiple of the absolute value of two numbers,
 using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.
 </p>
 Special cases:
 <ul>
 <li>The invocations <code>lcm(Long.MIN_VALUE, n)</code> and
 <code>lcm(n, Long.MIN_VALUE)</code>, where <code>abs(n)</code> is a
 power of 2, throw an <code>ArithmeticException</code>, because the result
 would be 2^63, which is too large for an int value.</li>
 <li>The result of <code>lcm(0L, x)</code> and <code>lcm(x, 0L)</code> is
 <code>0L</code> for any <code>x</code>.
 </ul></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - Number.</dd><dd><code>b</code> - Number.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the least common multiple, never negative.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result cannot be represented
 as a non-negative <code>long</code> value.</dd><dt><span class="strong">Since:</span></dt>
  <dd>2.1</dd></dl>
</li>
</ul>
<a name="mulAndCheck(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mulAndCheck</h4>
<pre>public static&nbsp;int&nbsp;mulAndCheck(int&nbsp;x,
              int&nbsp;y)
                       throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Multiply two integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Factor.</dd><dd><code>y</code> - Factor.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the product <code>x * y</code>.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be
 represented as an <code>int</code>.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.1</dd></dl>
</li>
</ul>
<a name="mulAndCheck(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mulAndCheck</h4>
<pre>public static&nbsp;long&nbsp;mulAndCheck(long&nbsp;a,
               long&nbsp;b)
                        throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Multiply two long integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - Factor.</dd><dd><code>b</code> - Factor.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the product <code>a * b</code>.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be represented
 as a <code>long</code>.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.2</dd></dl>
</li>
</ul>
<a name="subAndCheck(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subAndCheck</h4>
<pre>public static&nbsp;int&nbsp;subAndCheck(int&nbsp;x,
              int&nbsp;y)
                       throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Subtract two integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Minuend.</dd><dd><code>y</code> - Subtrahend.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the difference <code>x - y</code>.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be represented
 as an <code>int</code>.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.1</dd></dl>
</li>
</ul>
<a name="subAndCheck(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subAndCheck</h4>
<pre>public static&nbsp;long&nbsp;subAndCheck(long&nbsp;a,
               long&nbsp;b)
                        throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Subtract two long integers, checking for overflow.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>a</code> - Value.</dd><dd><code>b</code> - Value.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the difference <code>a - b</code>.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result can not be represented as a
 <code>long</code>.</dd><dt><span class="strong">Since:</span></dt>
  <dd>1.2</dd></dl>
</li>
</ul>
<a name="pow(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;int&nbsp;pow(int&nbsp;k,
      int&nbsp;e)
               throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                      <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Raise an int to an int power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>\( k^e \)</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result would overflow.</dd></dl>
</li>
</ul>
<a name="pow(int, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;int&nbsp;pow(int&nbsp;k,
                 long&nbsp;e)
               throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>As of 3.3. Please use <a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(int,%20int)"><code>pow(int,int)</code></a> instead.</i></div>
<div class="block">Raise an int to a long power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>k<sup>e</sup></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="pow(long, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;long&nbsp;pow(long&nbsp;k,
       int&nbsp;e)
                throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                       <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block">Raise a long to an int power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>\( k^e \)</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if the result would overflow.</dd></dl>
</li>
</ul>
<a name="pow(long, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;long&nbsp;pow(long&nbsp;k,
                  long&nbsp;e)
                throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>As of 3.3. Please use <a href="../../../../../org/apache/commons/math3/util/ArithmeticUtils.html#pow(long,%20int)"><code>pow(long,int)</code></a> instead.</i></div>
<div class="block">Raise a long to a long power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>k<sup>e</sup></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="pow(java.math.BigInteger, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;pow(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
             int&nbsp;e)
                      throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block">Raise a BigInteger to an int power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>k<sup>e</sup></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="pow(java.math.BigInteger, long)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;pow(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
             long&nbsp;e)
                      throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block">Raise a BigInteger to a long power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>k<sup>e</sup></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="pow(java.math.BigInteger, java.math.BigInteger)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;pow(<a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;k,
             <a href="http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</a>&nbsp;e)
                      throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></pre>
<div class="block">Raise a BigInteger to a BigInteger power.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>k</code> - Number to raise.</dd><dd><code>e</code> - Exponent (must be positive or zero).</dd>
<dt><span class="strong">Returns:</span></dt><dd>k<sup>e</sup></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>e &lt; 0</code>.</dd></dl>
</li>
</ul>
<a name="stirlingS2(int, int)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>stirlingS2</h4>
<pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
public static&nbsp;long&nbsp;stirlingS2(int&nbsp;n,
                         int&nbsp;k)
                       throws <a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a>,
                              <a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a>,
                              <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></pre>
<div class="block"><span class="strong">Deprecated.</span>&nbsp;<i>use <a href="../../../../../org/apache/commons/math3/util/CombinatoricsUtils.html#stirlingS2(int,%20int)"><code>CombinatoricsUtils.stirlingS2(int, int)</code></a></i></div>
<div class="block">Returns the <a
 href="http://mathworld.wolfram.com/StirlingNumberoftheSecondKind.html">
 Stirling number of the second kind</a>, "<code>S(n,k)</code>", the number of
 ways of partitioning an <code>n</code>-element set into <code>k</code> non-empty
 subsets.
 <p>
 The preconditions are <code>0 &lt;= k &lt;= n </code> (otherwise
 <code>NotPositiveException</code> is thrown)
 </p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - the size of the set</dd><dd><code>k</code> - the number of non-empty subsets</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>S(n,k)</code></dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NotPositiveException.html" title="class in org.apache.commons.math3.exception">NotPositiveException</a></code> - if <code>k &lt; 0</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/NumberIsTooLargeException.html" title="class in org.apache.commons.math3.exception">NumberIsTooLargeException</a></code> - if <code>k &gt; n</code>.</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if some overflow happens, typically for n exceeding 25 and
 k between 20 and n-2 (S(n,n-1) is handled specifically and does not overflow)</dd><dt><span class="strong">Since:</span></dt>
  <dd>3.1</dd></dl>
</li>
</ul>
<a name="isPowerOfTwo(long)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>isPowerOfTwo</h4>
<pre>public static&nbsp;boolean&nbsp;isPowerOfTwo(long&nbsp;n)</pre>
<div class="block">Returns true if the argument is a power of two.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>n</code> - the number to test</dd>
<dt><span class="strong">Returns:</span></dt><dd>true if the argument is a power of two</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/ArithmeticUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Class</li>
<li><a href="../../../../../org/apache/commons/math3/util/BigReal.html" title="class in org.apache.commons.math3.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/util/ArithmeticUtils.html" target="_top">Frames</a></li>
<li><a href="ArithmeticUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2003&#x2013;2016 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>
